from celery import Celery
from django.conf import settings
import os

# 1为celery设置环境变量,告诉celery为哪个Django项目提供服务
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blog.settings')
# 2创建Celery对象
app = Celery('blog')
# 3 配置celery应用
app.conf.update(BROKER_URL='redis://@127.0.0.1:6379/1')
# 4 设置自动加载任务
app.autodiscover_tasks(settings.INSTALLED_APPS)
